<?
// *************************************
// * user.php allows the admin to
// * View and Delete admin users.
// *************************************
$sajax = 1;
define('SITE_AREA', 'contacts');

$jsFile = "jsContacts.js";
include("includes/functions.php");
include($pre."includes/sajax/sajaxContacts.php");

sajax_init();
$sajax_request_type = "POST"; 
sajax_export("getContactsByProgram");
sajax_export("getContactsByLastName");
sajax_export("getContactsForProgram");
sajax_export("saveContact");
sajax_export("deleteContact");
sajax_export("getContactForEdit");
sajax_export("getProgramDetails");
sajax_export("saveProgram");
sajax_handle_client_request();

$programArray = getProgramDetails($_SESSION[programID]);
if ($_SESSION['userLevel'] != 1) {
	$pName = $programArray[1];
}

include("includes/header.php"); ?>
	<div id="addEditFormDiv" style="display: none;"></div>	
	
	<div id="content0">
		<input type="hidden" id="itemID" value="0" />
		<div id="sortButtons" style="float: right;">
			<input id="buttonSortProgram" style="display: none;" type="button" value="Sort by CASA Program" onClick="contactsViewObj.getContactsByProgram();" />
			<input id="buttonSortLastName" type="button" value="Sort by Last Name" onClick="contactsViewObj.getContactsByLastName();" />
			<input type="button" value="Print" style="margin-left: 10px;" onClick="goPrint('contacts',0);" />
		</div>
		<div style="clear: right; margin-bottom: 10px;"></div>
		
		<!-- This is where the entire list goes -->
		<div id="contactsContainer"></div>
	</div>
	
	<div id="content1">
		<div id="buttonNew" style="float: left; width: 180px;"><input type="button" class="buttonBig buttonAddBig" value="New Contact" onClick="contactsAddObj.addContact();" title="Add new contact" id="buttonAddContact" /></div>
		<div id="statusDiv" style="float: left;"></div>
		<div style="clear: left; height: 10px;"></div>
		
		<div id="content1FormDiv">
			<div id="formNewContact" class="blueBox" style="display: none;">		
				<input type="hidden" id="formAction" />
				<input type="hidden" id="uID" />
				<input type="hidden" id="mainProgramID" value="<?=$_SESSION[programID]; ?>" />
				
				<p><label class="vertLabel">Select Program</label>
					<select size="1" style="width: 400px;" id="uProgram">
					<option>Select...</option>
					<option></option>
					<? echo getPrograms('select',$_SESSION['programID']); ?>
					</select>				
				</p>
				
				<p><label class="vertLabel">Name</label>
				<input type="text" style="width: 195px; margin-right: 5px;" value="First Name" id="uNameFirst" onFocus="this.value='';" />
				<input type="text" style="width: 195px;" value="Last Name" id="uNameLast" onFocus="this.value='';"  />
				</p>
				
				<p><label class="vertLabel">Phone Numbers</label>
				<input type="text" style="width: 195px; margin-right: 5px;" value="Phone 1" id="uPhone1" onFocus="this.value='';" />
				<input type="text" style="width: 195px;" value="Phone 2" id="uPhone2" onFocus="this.value='';"  />
				</p>
				
				<p><label class="vertLabel">Email Address</label>
				<input type="text" style="width: 400px;" id="uEmail" name="uEmail" /></p>
							
				<p><label class="vertLabel">Office Number</label>
				<input type="text" style="width: 200px;" id="uOfficeNo" name="uOfficeNo" /></p>
									
				<p><label class="vertLabel">Position</label>
					<select size="1" style="width: 200px;" id="uPosition">
					<option>Select...</option>
					<option></option>
					<? echo getCategories('select','P'); ?>
					</select>				
				</p>
									
				<p>
				<input type="checkbox" id="uPublic" name="uPublic" />
				Make this contact public (viewable on the CASA3G website)
				</p>
													
				<p style="margin-top: 15px; margin-left: 6px;">
					<input type="button" class="buttonBig buttonSaveBig" onClick="contactsSaveObj.saveContact();" value="Save" title="Save user" />
					<input type="button" class="buttonBig buttonCancelBig" onClick="contactsSupportObj.closeContactForm();" value="Cancel" title="Cancel" />
				</p>
				
			</div>
		</div>
		<div id="programInfoBlock">
			<? if ($_SESSION['userLevel'] != 1) { ?>
			<div id="programInfo<?=$_SESSION[programID]; ?>">			
				<div style="float: left;">
				<a href="#" onClick="programEditObj.editProgram(<?=$_SESSION[programID]; ?>); return false;" title="Edit program information"><img src="images/iconEditSmall.gif" style="border: none;" /></a>&nbsp;
				</div><div style="float: left;">
				<h1 id="programName<?=$_SESSION[programID]; ?>"><?=$pName; ?></h1>
				</div>
				<div style="clear: left;"></div>
			</div>	
			<div id="programForm<?=$_SESSION[programID]; ?>"></div>
			<? } ?>
		</div>
		<div id="programContactDisplay"></div>
	</div>
		
	<div id="south" class="x-layout-inactive-content">
	south - generally for informational stuff, also could be for status bar
	</div>
<? include("includes/footer.php"); ?>